package com.baifendian.service.impl;

import com.baifendian.common.utils.DateUtils;
import com.baifendian.dao.entity.RcApiInterStat;
import com.baifendian.dao.mapper.ExcApiTrackMapper;
import com.baifendian.dao.mapper.RcApiInterStatMapper;
import com.baifendian.service.RcApiInterStatService;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

/**
 * @author peng.guo on 2018/3/7.
 */
@Service
public class RcApiInterStatImpl implements RcApiInterStatService{

  @Resource
  private ExcApiTrackMapper excApiTrackMapper;

  @Resource
  private RcApiInterStatMapper rcApiInterStatMapper;

  @Override
  public List<RcApiInterStat> getInterApiByGroup(Date date) {
    return excApiTrackMapper.getInterApiByGroup(date);
  }

  @Override
  public void saveRcApiInterStat(List<RcApiInterStat> rcApiInterStatList) {
    for(RcApiInterStat rcApiInterStat : rcApiInterStatList){
      if(ObjectUtils.isEmpty(rcApiInterStat)){
        continue;
      }
      rcApiInterStat.setStatDate(DateUtils.localDateTimeToDate(DateUtils.getCurrentTime()));
      rcApiInterStatMapper.insertSelective(rcApiInterStat);
    }
  }

  @Override
  public void delRcApiInterStat() {
    rcApiInterStatMapper.delRcApiInterStat();
  }


}
